//
//  SSTabBarController.swift
//  BigProject
//
//  Created by Gmc on 2018/6/12.
//  Copyright © 2018年 Gmc. All rights reserved.
//

import UIKit

class SSTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        tabBar.backgroundImage = UIImage.init()
//        tabBar.backgroundColor = UIColor.white
        
        if (CheckDate.check(date: "04-04") || CheckDate.check(date: "12-13")) {
            tabBar.tintColor = UIColor.colorWithHexString(hexString: "272727")
        } else {
            tabBar.tintColor = UIColor.colorWithHexString(hexString: "00BFFF")
        }

        self.initSubViews()
    }
    
    func initSubViews() -> Void {
        initSubViews(title: "Lesson", VcName: "BBLesson", imageName: "lesson")
        initSubViews(title: "Book", VcName: "BBBook", imageName: "book")
        initSubViews(title: "Yo", VcName: "BBYo", imageName: "yo")
    }
    
   @objc func initSubViews(title:String, VcName:String, imageName:String) -> Void {
    
    let nameSpace = Bundle.main.infoDictionary!["CFBundleExecutable"] as? String
    
    let classType = NSClassFromString(nameSpace! + "." + VcName) as? UIViewController.Type
    let vc = classType?.init()
//    vc?.tabBarItem.title = title
    vc?.title = title
    vc?.tabBarItem.image = UIImage.init(named: imageName)
    vc?.tabBarItem.selectedImage = UIImage.init(named: imageName + "_selected")
    guard let addVc = vc else {
        return
    }
    let nav = SSNavigationController.init(rootViewController: addVc)
    self.addChild(nav)
    
    }
}
